home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / compre1a / runthrou.frm < prev   
Text File  |  1999-08-31  |  4KB  |  139 lines

  1. VERSION 5.00
  2. Object = "{F5BE8BC2-7DE6-11D0-91FE-00C04FD701A5}#2.0#0"; "AGENTCTL.DLL"
  3. Begin VB.Form frmScript 
  4.    Caption         =   "Running through a set script"
  5.    ClientHeight    =   1635
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   1635
  11.    ScaleWidth      =   4680
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Label Label1 
  14.       Height          =   315
  15.       Left            =   420
  16.       TabIndex        =   0
  17.       Top             =   1020
  18.       Width           =   3495
  19.    End
  20.    Begin AgentObjectsCtl.Agent Agent 
  21.       Left            =   360
  22.       Top             =   300
  23.       _cx             =   847
  24.       _cy             =   847
  25.    End
  26. End
  27. Attribute VB_Name = "frmScript"
  28. Attribute VB_GlobalNameSpace = False
  29. Attribute VB_Creatable = False
  30. Attribute VB_PredeclaredId = True
  31. Attribute VB_Exposed = False
  32. Option Explicit
  33.  
  34. Dim Genie As IAgentCtlCharacter
  35. Dim Merlin As IAgentCtlCharacter
  36. Dim LoadRequest(3)
  37. Dim GenieRequest As IAgentCtlRequest
  38. Dim MerlinRequest As IAgentCtlRequest
  39.  
  40. Private Sub Agent_RequestComplete(ByVal Request As Object)
  41.     Select Case Request
  42.         Case LoadRequest(1)
  43.             If Request.Status <> 0 Then
  44.                 ' If genie's character data fails to load post a message
  45.                 Label1.Caption = "Genie character failed to load."
  46.  
  47.                 MsgBox "Unable to load the Genie character. Program will terminate"
  48.                 Unload Me
  49.             Else
  50.                 Label1.Caption = "Genie character successfully loaded."
  51.                 'Create a reference to the character
  52.                 Set Genie = Agent.Characters("Genie")
  53.                 Call GenieIntro
  54.             End If
  55.  
  56.         Case LoadRequest(2)
  57.             If Request.Status <> 0 Then
  58.                 Label1.Caption = "Merlin character failed to load."
  59.                 Genie.Speak "Uh oh, Merlin failed to load."
  60.                 Genie.Speak "You'll have to exit!"
  61.                 Genie.Hide
  62.             Else
  63.                 Label1.Caption = "Merlin character successfully loaded."
  64.                 Set Merlin = Agent.Characters("Merlin")
  65.                 Call MerlinIntro
  66.             End If
  67.         Case LoadRequest(3)
  68.             Unload Me
  69.     End Select
  70. End Sub
  71.  
  72. Private Sub LoadGenie()
  73.     Set LoadRequest(1) = Agent.Characters.Load("Genie", "Genie.acs")
  74.     Label1.Caption = "Loading Genie character."
  75. End Sub
  76.  
  77. Private Sub LoadMerlin()
  78.     Set LoadRequest(2) = Agent.Characters.Load("Merlin", "Merlin.acs")
  79.     Label1.Caption = "Loading Merlin character."
  80. End Sub
  81.  
  82. Private Sub GenieIntro()
  83.     Genie.MoveTo 170, 240
  84.     Genie.Show
  85.     Genie.Speak "Hello!  I am Genie, a Microsoft Agent Character"
  86.     Genie.Play "Greet"
  87.     Genie.Speak "and I am at your service"
  88.     Genie.Play "Blink"
  89.     
  90.     Genie.Speak "I hope Geeza's code will help you to create Agent scripts easily too, and get around the problem that we can't pronounce Geeza correctly.  \pau=200\G-eeza, \pau=200\GG eeza..."
  91.     
  92.     Call LoadMerlin
  93.  
  94.     Set GenieRequest = Genie.Speak("But for now, here's Merlin!")
  95.     Genie.Play "LookLeft"
  96. End Sub
  97.  
  98. Private Sub MerlinIntro()
  99.     Merlin.MoveTo 320, 240
  100.     Merlin.Wait GenieRequest
  101.     Merlin.Show
  102.     Merlin.Play "Wave"
  103.     Merlin.Speak "Hello to you all.  I am Merlin; another Microsoft Agent Character"
  104.     Merlin.Play "Blink"
  105.  
  106.     Call Routine1
  107. End Sub
  108.  
  109. Private Sub Routine1()
  110.     Genie.Play "Blink"
  111.     
  112.     Call Time_For_Tubbie_Bye_Byes
  113. End Sub
  114.  
  115. Private Sub Time_For_Tubbie_Bye_Byes()
  116.     Merlin.Wait GenieRequest
  117.     Set MerlinRequest = Merlin.Speak("So it's goodbye from me,")
  118.     Genie.Wait MerlinRequest
  119.     Set GenieRequest = Genie.Speak("And it's goodbye from him")
  120.     Merlin.Wait GenieRequest
  121.     Set MerlinRequest = Merlin.Speak("Goodnight")
  122.     Genie.Wait MerlinRequest  'I had to do it, sorry!
  123.     Genie.Hide                'The Two Ronnie's rocked :)
  124.     Set LoadRequest(3) = Merlin.Hide
  125. End Sub
  126.  
  127. Private Sub Form_Load()
  128.     Call LoadGenie
  129. End Sub
  130.  
  131. 'This is a very much earlier version of the other script,
  132. 'but it shows how to make a continuous script for the
  133. 'Agents, without the dreaded
  134. '"Variable without Block variable set" or whatever it is,
  135. 'enjoy!
  136.  
  137. 'GEEZA
  138. 'Off to the land of Dreams ~~~~~~~~~~~~~~
  139.